#include"Logger.h"
using namespace std;

namespace moqi
{

Logger *Logger:: _pInstance = nullptr;

Logger*Logger:: getInstance()
{
    if(_pInstance==nullptr)
    {
        _pInstance=new Logger();
    }
    return _pInstance;
}
void Logger:: destory()
{
    if(_pInstance!=nullptr)
    {
        Category::shutdown();
        delete _pInstance;
        _pInstance=nullptr;
    }
}

Logger::Logger():
 _root(log4cpp::Category::getRoot())
{

    std::string initFileName = "log4cpp.properties";
    log4cpp::PropertyConfigurator::configure(initFileName);


//    PatternLayout * ptn1 = new PatternLayout();
//    ptn1->setConversionPattern("%d %c [%p] %m%n");
//
//    PatternLayout * ptn2 = new PatternLayout();
//    ptn2->setConversionPattern("%d %c [%p] %m%n");
//
//    PatternLayout * ptn3 = new PatternLayout();
//    ptn3->setConversionPattern("%d %c [%p] %m%n");
//
//    OstreamAppender *appender1 = new OstreamAppender("console", &std::cout);
//    appender1->setLayout(ptn1);
//
//    FileAppender *appender2 = new FileAppender("default", "aliyun.log");
//    appender2->setLayout(ptn2);
//
//    RollingFileAppender  *appender3 = new RollingFileAppender("rollinfile", "aliyunrolling.log",5*1024,9);
//    appender3->setLayout(ptn3);
//
//    _root->setPriority(log4cpp::Priority::DEBUG);
//    _root->addAppender(appender1);
//    _root->addAppender(appender2);
//    _root->addAppender(appender3);
}
Logger::~ Logger(){
    cout<<"~Logger()"<<endl;

}
}//end of namespace moqi
